<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Services\StoreOrderService;

class BaseIndexController extends CommonController{

    public function __construct(Request $request){
       parent::__construct($request);
       $this->storeOrderService = new StoreOrderService();
    }
    
    /**
     * 信息列表
     */
    function index(){
    	$nowSTime = date('Y-m-d').' 00:00:00';
    	$nowETime = date('Y-m-d').' 23:59:59';
    	$todayNumResult = $this->storeOrderService->selectSql("select count(*) as todayNum from xk_store_order where status > 0 and created_at >= '{$nowSTime}' and created_at <= '{$nowETime}'");
    		
    	$todayMoneyResult = $this->storeOrderService->selectSql("select sum(total_price) as totayMoney from xk_store_order where status > 0 and created_at >= '{$nowSTime}' and created_at <= '{$nowETime}'");
    	
    	$totalNumResult = $this->storeOrderService->selectSql("select count(*) as totalNum from xk_store_order where status > 0");
    		
    	$totalMoneyResult = $this->storeOrderService->selectSql("select sum(total_price) as totalMoney from xk_store_order where status > 0");
   
   		$todayNum = $todayNumResult['data'][0]->todayNum;
   		$todayMoney = $todayMoneyResult['data'][0]->totayMoney;
   		$totalNum = $totalNumResult['data'][0]->totalNum;
   		$totalMoney = $totalMoneyResult['data'][0]->totalMoney;
    	return view('index',['todayNum'=>$todayNum,'todayMoney'=>$todayMoney,'totalNum'=>$totalNum,'todayMoney'=>$todayMoney]);
    }
    
   
}
